<script setup lang='ts'>
import { ref, watch } from 'vue';

const count = ref(0)
const name = ref("123")
//  侦听器单个的用法
//  watch(count, (newValue, oldValue) => {
//    console.log(newValue, oldValue)
//  })
// 监听多个的响应式数据-newValue和oldValue是数组，顺序按照传入顺序排列
watch([count, name], (newValue, oldValue) => {
    console.log("新值" + newValue, "旧值" + oldValue)
})
</script>

<template>
    <h1>Watch最简单用法</h1>
    <button @click="count--">-</button>
    <span>{{ count }}</span>
    <button @click="count++">+</button>
    <input type="text" v-model="name">
</template>

<style scoped></style>